package com.offcn.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 配置常量类
 */
@Component
public class ConstantPropertiesUtils implements InitializingBean {

    //读取配置文件内容
    @Value("${spring.cloud.alicloud.access-key}")
    public String accessId;
    @Value("${spring.cloud.alicloud.oss.endpoint}")
    public String endpoint;
    @Value("${spring.cloud.alicloud.oss.bucket}")
    public String bucket;
    @Value("${spring.cloud.alicloud.secret-key}")
    public String secret;

    //定义公开的常量
    public static String END_POIND;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        ACCESS_KEY_ID = accessId; //ID
        ACCESS_KEY_SECRET = secret; //密钥
        BUCKET_NAME = bucket; //名称
        END_POIND = endpoint; //地域节点
    }
}
